package com.sikaryofficial.system.api;

import com.sikaryofficial.common.core.domain.R;
import com.sikaryofficial.system.api.config.HiSMKDigClientConfiguration;
import com.sikaryofficial.system.api.domain.SysUser;
import com.sikaryofficial.system.api.domain.order.OrderCustomizedOpReq;
import com.sikaryofficial.system.api.factory.OuterNetWorkbenchFallbackFactory;
import com.sikaryofficial.system.api.model.FileInfo;
import com.sikaryofficial.system.api.model.outer.OrderPayInfoResp;
import com.sikaryofficial.system.api.model.outer.UploadPaymentVoucherReq;
import io.swagger.annotations.ApiParam;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.util.List;

@FeignClient(name = "outerNetWorkbenchService", url = "${server-url.hismk-dig-api-workbench}",
        fallbackFactory = OuterNetWorkbenchFallbackFactory.class, configuration = HiSMKDigClientConfiguration.class)
public interface OuterNetWorkbenchService {

    /**
     * 获取用户签署视图。签署完成后也可以用，只能查看
     *
     * @param orderHeaderId
     * @return
     */
    @GetMapping("/order/api/getCustomerContractUrl")
    R<String> getCustomerContractUrl(@RequestParam("orderHeaderId") Long orderHeaderId);


    /**
     * 获取支付信息
     *
     * @param orderHeaderId
     * @param payType
     * @return
     */
    @GetMapping("/order/api/getPayInfo")
    R<OrderPayInfoResp> getPayInfo(@ApiParam("订单id") @RequestParam("orderHeaderId") Long orderHeaderId,
                                   @ApiParam(value = "支付类型 1-首付款 2-尾款") @RequestParam("payType") Integer payType);

    /**
     * 上传支付凭证
     *
     * @param req
     * @return
     */
    @PostMapping("/order/api/uploadPaymentVoucher")
    R<Boolean> uploadPaymentVoucher(@RequestBody UploadPaymentVoucherReq req);

    /**
     * 获取发货单文件
     *
     * @param orderHeaderId
     * @return
     */
    @GetMapping("/order/api/getShipmentFile")
    R<List<FileInfo>> getShipmentFile(@RequestParam("orderHeaderId") Long orderHeaderId);

    /**
     * 文件上传至内网obs
     *
     * @param file
     * @return
     */
    @PostMapping(value = "/public/attachment/upload", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
    R<String> upload(@RequestPart("file") MultipartFile file);

    @PostMapping("/order/customized/api/confirmOrReject")
    R<Void> confirmOrderCustomized(@RequestBody OrderCustomizedOpReq opReq);

    @GetMapping(value = "/customer/salesPhone/{customerUserId}")
        R<SysUser> getSalesPhone(@PathVariable("customerUserId") Long customerUserId);
}
